package com.ruoyi.web.controller.biz;

import java.util.List;

import com.ruoyi.biz.domain.MaintainType;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.service.IMaintainTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2020-11-30
 */
@RestController
@RequestMapping("/system/maintain/type")
public class MaintainTypeController extends BaseController
{
    @Autowired
    private IMaintainTypeService maintainTypeService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:list')")
    @GetMapping("/list")
    @ApiOperation("查询保养类别列表")
    public TableDataInfo list(MaintainType maintainType)
    {
        startPage();
        List<MaintainType> list = maintainTypeService.selectMaintainTypeList(maintainType);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出保养类别信息")
    public AjaxResult export(MaintainType maintainType)
    {
        List<MaintainType> list = maintainTypeService.selectMaintainTypeList(maintainType);
        ExcelUtil<MaintainType> util = new ExcelUtil<MaintainType>(MaintainType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:query')")
    @GetMapping(value = "/{maintainTypeId}")
    @ApiOperation("获取保养类别信息")
    public AjaxResult getInfo(@PathVariable("maintainTypeId") Long maintainTypeId)
    {
        return AjaxResult.success(maintainTypeService.selectMaintainTypeById(maintainTypeId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增保养类别信息")
    public AjaxResult add(@RequestBody MaintainType maintainType)
    {
        return toAjax(maintainTypeService.insertMaintainType(maintainType));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping("edit")
    @ApiOperation("修改保养类别信息")
    public AjaxResult edit(@RequestBody MaintainType maintainType)
    {
        return toAjax(maintainTypeService.updateMaintainType(maintainType));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:maintain:type:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{maintainTypeIds}")
    @ApiOperation("删除保养类别信息")
    public AjaxResult remove(@PathVariable Long[] maintainTypeIds)
    {
        return toAjax(maintainTypeService.deleteMaintainTypeByIds(maintainTypeIds));
    }
}
